
var flag = false;
// @Bind #btnModify.onClick
!function() {
	view.get("#dialogEdit").show();
}

//@Bind #btnCancel.onClick
!function(){
    view.get("#dialogEdit").hide();
	if (flag) {
		flag = false;
		view.get("#dsWriteInvestigates.data:#").remove()
	}
	
}

// @Bind #dialogEdit.onClose
!function() {
	if (flag) {
		flag = false;
		view.get("#dsWriteInvestigates.data:#").remove()
	}
	
}

//@Bind #btnConfirm.onClick
!function(){
    var dialog = view.get("#dialogEdit");
    view.get("#updateAction").execute(function(){
        dialog.hide();
    })
}

// @Bind #categoryTree.onDataRowClick
!function (self) {

     var entity = self.getCurrentItem()._data
   	 view.get("#customDropDown1").close(entity)
	var entity = view.get("#dsWriteInvestigates").getData("#")
	entity.set({"title":"","author":"","name":"","content":""})

}

// @Bind #btnAdd.onClick
!function() {
	view.get("#dsWriteInvestigates.data").insert();
    view.get("#dialogEdit").show();
	flag = true;
}

//@Bind #btnDel.onClick
!function(){
 var entity = view.get("#dsWriteInvestigates.data:#");
    if(entity){
        dorado.MessageBox.confirm("确认要删除记录吗？", function(){
            entity.remove();
			
        })	 
    }   
}

// @Bind #btnQuery.onClick
!function() {
    var title = view.get("#titleSearch").get("value");
    var name = view.get("#nameSearch").get("value");
	var type = view.get("#queryType").get("value")
    param = {"title":title, "name":name, "type":type};
    var dsInvestigates = view.get("#dsWriteInvestigates");
    dsInvestigates.set("parameter",param);
    dsInvestigates.flushAsync();
}

// @Bind #queryType.onClick
!function(self) {
	var param = self.get("value");
	view.get("#updateAction").set("parameter",param);
}
// @Bind #ddInvestigate.beforeExecute
!function() {
	var categoryId = view.get("#dsWriteInvestigates.data:#").get("categoryId")
	//alert(JSON.stringify(categoryId))
	if (categoryId) {
		var dsInvestigates = view.get("#dsInvestigates")
		dsInvestigates.set("parameter",categoryId)
		dsInvestigates.flushAsync();
	}
}

